<%@ page contentType="text/html;charset=ISO-8859-1" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<c:set var="insertUpdateTitle" value="${!empty eventoForm.id && eventoForm.id != 0 ?'Atualizar evento':'Adicionar evento'}"/>
<head>
    <link href="resources/css/layout.css" rel="stylesheet" type="text/css" />
    <title><fmt:message key="label.eventos"/></title>

    <script type="text/javascript">
        function Data(v){
            document.forms[0].data.value = v.replace(/\D/g,"")
            document.forms[0].data.value=document.forms[0].data.value.replace(/(\d{2})(\d)/,"$1/$2")
            document.forms[0].data.value=document.forms[0].data.value.replace(/(\d{2})(\d)/,"$1/$2")
            return document.forms[0].data.value;
        }
        
        function Telefone(v){
            document.forms[0].telefone.value=v.replace(/\D/g,"")
            document.forms[0].telefone.value=document.forms[0].telefone.value.replace(/^(\d\d)(\d)/g,"($1) $2")
            document.forms[0].telefone.value=document.forms[0].telefone.value.replace(/(\d{4})(\d)/,"$1-$2")
            return document.forms[0].telefone.value;
        }
    </script>
</head>
<body>
    <div class="titleDiv"><fmt:message key="application.title"/></div>
    <br />
    <h1>${insertUpdateTitle}</h1>
    <br />
    <html:form action="/eventoProcess">

        <html:hidden property="idUsuario" />
        <html:hidden property="id" />
        <input type="hidden" name="dispatch" value="insereAtualiza" />

        <table>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.nome"/>:</td>
                <td><html:text property="nome" size="40" maxlength="100" /> <html:errors property="nome"/></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.descricao"/>:</td>
                <td><html:text property="descricao" size="60" maxlength="100" /> <html:errors property="descricao" /></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.local"/>:</td>
                <td><html:text property="local" size="60" maxlength="100" /> <html:errors property="local" /></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.cidade"/>:</td>
                <td><html:text property="cidade" size="40" maxlength="60" /> <html:errors property="cidade" /></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.nomePromotor"/>:</td>
                <td><html:text property="nomePromotor" size="40" maxlength="60" /> <html:errors property="nomePromotor" /></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.telefone"/>:</td>
                <td><html:text property="telefone" size="20" maxlength="14" onkeyup="Telefone(this.value);" /> <html:errors property="telefone" /></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.observacao"/>:</td>
                <td><html:textarea property="observacao" cols="80" rows="4" /> <html:errors property="observacao" /></td>
            </tr>
            <tr>
                <td class="tdLabel"><fmt:message key="label.evento.data"/>:</td>
                <td>
                    <html:text property="data" size="20" onkeyup="Data(this.value);" maxlength="10" />
                    <html:errors property="data"/>
                </td>
            </tr>
        </table>
        <div id="divBotoes">
            <input type="submit" value="<fmt:message key="button.label.gravar" />" class="butStnd"/>
            &nbsp;&nbsp;&nbsp;
            <c:url var="url" scope="page" value="/listaEventos.do">
                <c:param name="dispatch" value="getEventos"/>
                <c:param name="idUsuario" value="${usuario}" />
            </c:url>
            <input type="button" value="<fmt:message key="button.label.cancelar" />"  class="butStnd" onclick="document.location.href='${url}'"/>

        </div>
    </html:form>
</body>
</html>